package cn.com.headfree.competent.service.impl;

import cn.com.headfree.entity.TEmpBaseInfo;
import cn.com.headfree.entity.TSeniorCompetent;
import cn.com.headfree.competent.service.ExportWordUserDataInfoService;
import cn.com.headfree.competent.service.IUserDataInfoService;
import cn.com.headfree.vo.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("exportWordUserDataInfoService")
public class ExportWordUserDataInfoServiceImpl implements ExportWordUserDataInfoService {

	private static final Logger LOG = LogManager.getLogger(ExportWordUserDataInfoServiceImpl.class);

	@Autowired
	private IUserDataInfoService userDataInfoService;


	@Override
	public CompetentReportVo getModelData(String erpNo, String seniorId, Date acquTime) {
		//基本信息
		TEmpBaseInfo tEmpBaseInfo = userDataInfoService.getBaseInfoByErpNo(erpNo);
		//申报的信息
		TSeniorCompetent competent = userDataInfoService.getTSeniorCompetentById(seniorId);
		//在岗现状
		List<WorkExpInfoVo> tWorkExpStatus = userDataInfoService.getWorkStatusExpInfoByErpNo(erpNo,seniorId);
		//学历、学位情况
		List<EducateInfoVo> educateInfos = userDataInfoService.getEducateInfoByErpNo(erpNo,seniorId);
		//学习、培训经历
		List<StudyAndTrainVo> studyAndTrainVos = userDataInfoService.getContiStudyInfoByErpNo(erpNo,seniorId);
		//主要工作经历
		List<WorkExpInfoVo> tWorkExpInfos = userDataInfoService.getWorkExpInfoByErpNo(erpNo,seniorId);
		//取得现专业技术资格后的工作成果--科技成果奖励
		List<TecManInnovVo> tecManInnovVos = userDataInfoService.getTecManInnovByErpNo(erpNo,seniorId,acquTime);
		//取得现专业技术资格后的工作成果--荣誉称号
		List<HonorDatasVo> honorDatasVos = userDataInfoService.getHonnorInfoByErpNo(erpNo,seniorId,acquTime);
		//取得现专业技术资格后的作品成果--学术成果
		List<AcadeAchiveVo> acadeAchiveVos = userDataInfoService.getAcadeAchiveInfoByErpNo(erpNo,seniorId,acquTime);
		//取得现专业技术资格后的作品成果--标准制定
		List<StandInfoVo> standInfoVos = userDataInfoService.getStandInfoByErpNo(erpNo,seniorId,acquTime);
		//专家称号
		List<ExpertTitleVo> expertTitleInfos = userDataInfoService.getExpertTitleInfoByErpNo(erpNo,seniorId);
		//近三年绩效
		List<YearEffectVo> yearEffectVos = userDataInfoService.getYearEffectByErpNo(erpNo);

		//拼装数据
		CompetentReportVo competentReportVo = new CompetentReportVo();
		LOG.info("===============组装模板数据开始=================");
		competentReportVo.settEmpBaseInfo(tEmpBaseInfo);
		if(competent != null){
			competentReportVo.settSeniorCompetent(competent);
		}
		if(tWorkExpStatus != null && tWorkExpStatus.size() >0){
			competentReportVo.setWorkExpInfoVo(tWorkExpStatus.get(0));
		}
		if(educateInfos != null && educateInfos.size() >0){
			competentReportVo.setEducateInfoVos(educateInfos);
		}
		if(studyAndTrainVos != null && studyAndTrainVos.size() >0){
			competentReportVo.setStudyAndTrainVos(studyAndTrainVos);
		}
		if(tWorkExpInfos != null && tWorkExpInfos.size() >0){
			competentReportVo.setWorkExpInfoVos(tWorkExpInfos);
		}
		if(tecManInnovVos != null && tecManInnovVos.size() >0){
			competentReportVo.setTecManInnovVos(tecManInnovVos);
		}
		if(honorDatasVos != null && honorDatasVos.size() >0){
			competentReportVo.setHonorDatasVos(honorDatasVos);
		}
		if(acadeAchiveVos != null && acadeAchiveVos.size() >0){
			competentReportVo.setAcadeAchiveVos(acadeAchiveVos);
		}
		if(standInfoVos != null && standInfoVos.size() >0){
			competentReportVo.setStandInfoVos(standInfoVos);
		}
		if(expertTitleInfos != null && expertTitleInfos.size() >0){
			competentReportVo.setExpertTitleVos(expertTitleInfos);
		}
		if(yearEffectVos != null && yearEffectVos.size() >0){
			competentReportVo.setYearEffectVos(yearEffectVos);
		}

		LOG.info("======================数据组装完成========================");
		return competentReportVo;
	}


}
